package model;

public class Value {

	private double value = -1;

	public Value(Object object) {
		try {
			value = Double.parseDouble(object.toString());
		} catch (Exception e2) {
		}
	}

	public Value(double d) {
		value = d;
	}

	public int toInt() {
		return (int) value;
	}

	@Override
	public String toString() {
		return "" + value;
	}

	public static Value pot(Value v1, Value v2) {
		double x = v1.value;
		double y = 1;
		for (int i = 0; i < v2.value; i++) {
			y = y * x;
		}
		return new Value(y);
	}

	public static Value add(Value v1, Value v2) {
		return new Value(v1.value + v2.value);
	}

	public static Value sub(Value v1, Value v2) {
		return new Value(v1.value - v2.value);
	}

	public static Value mult(Value v1, Value v2) {
		return new Value(v1.value * v2.value);
	}

	public static Value div(Value v1, Value v2) {
		return new Value(v1.value / v2.value);
	}

	public double toDouble() {
		return value;
	}

}
